<?php
	$_SETTING['sidebar'] = "FALSE";
	include $_SERVER['DOCUMENT_ROOT']."/include/header.php";
	
	$div_left_content = array(name=>"left_content",custom=>"height:auto; width:0%; float:left;");
	$div_right_content = array(name=>"right_content",custom=>"height:auto; width:100%; float:right; ");
	//$div1 = array(name=>"div1",custom=>"min-height:20px; width:95%; padding:20px 0px 0px 10px;");
	$div2 = array(name=>"div2",custom=>"min-height:20px; width:95%; float:right; padding:20px 20px 0px 0px;");
	//$div3 = array(name=>"div3",custom=>"min-height:20px; width:95%; float:right; padding:20px 20px 0px 0px;");
	//$div4 = array(name=>"div4",custom=>"min-height:20px; width:95%; padding:20px 0px 0px 10px;");
	
	createDiv($div_left_content);
	createDiv($div_right_content);
	//createDiv($div1);
	createDiv($div2);
	//createDiv($div3);
	//createDiv($div4);
	checkAccess(array('roles'=>array(null)));
?>
<script type="text/javascript">
function checkform()
	{
			var userLength=document.getElementById("idUser").value.length;
			var passLength=document.getElementById("idPass").value.length;
			var emailLength=document.getElementById("idEmail").value.length;
			var nameLength=document.getElementById("idName").value.length;
			var surnameLength=document.getElementById("idSurname").value.length;
			//var pCodeLength=document.getElementById("idPcode").value.length;		
			//var addressLength=document.getElementById("idAddress").value.length;
			var repassValue=document.getElementById("idrepass").value;
			var passValue=document.getElementById("idPass").value;	
					
		if(passLength==0)
			{
				alert("กรุณากรอก Password ด้วยครับ");
				return false;
			}
		
		if(userLength==0)
			{
				alert("กรุณากรอก Username ด้วยครับ");
				return false;
			}
		
		if(emailLength==0)
			{
				alert("กรุณากรอก email ด้วยครับ");
				return false;
			}
		if(nameLength==0)
			{
				alert("กรุณากรอก name ด้วยครับ");
				return false;
			}
		if(surnameLength==0)
			{
				alert("กรุณากรอก surname ด้วยครับ");
				return false;
			}
		/*if(pCodeLength==0)
			{
				alert("กรุณากรอก Personal Code ด้วยครับ");
				return false;
			}
		if(addressLength==0)
			{
				alert("กรุณากรอก Address ด้วยครับ");
				return false;
			}*/
		if(repassValue!=passValue)
			{
				alert("Confirm Password Not Match");
				return false;
			}
		
		if(!validateCaptcha())
		{
			alert("Captcha wrong");
			return false;
		}
	}
</script>

<script type="text/javascript">
function validateUser()
		{
			//jquery ใช้ id ของ textbox เป็นตัวอ้างอิง
		
			$.get("registeraction.php",{username:$('#idUser').val()},function(dataresponse)
			{
				$('#usernameMessage').html(dataresponse);
				//alert(dataresponse);
			});
		}
</script>
<div class="left_content">
</div>

<div class="right_content">	
<!-- box begin -->
						<div class="div2" align="center" >
							<div class="border-top">
								<div class="border-right">
									<div class="border-bot">
										<div class="border-left">
											<div class="left-top-corner">
												<div class="right-top-corner">
													<div class="right-bot-corner">
														<div class="left-bot-corner">
															<div class="inner">
															<h3>Register</h3>
<!--  Start Coding Here -->
<div id="form_container">
<form id="form1" name="RegisterForm" method="post" action="registeraction.php" class="niceform" onsubmit="return checkform();" enctype="multipart/form-data">
<fieldset>
    	<legend>ลงทะเบียนสมาชิก</legend>
  <dl>  
    <dt><label for="username">Username</label></dt>
    <dd><input type="text" name="username" id="idUser" onchange="validateUser();"/> <span id="usernameMessage"> </span> </dd>
  </dl>
  
  <dl>
    <dt><label for="password">Password</label></dt>
    <dd><input type="password" name="password" id="idPass" /></dd>
  </dl>
  
  <dl>
    <dt><label for="Confirm_password">Re-Password</label></dt>
    <dd><input type="password" name="confPassword" id="idrepass" /></dd>
  </dl>
  
  <dl>
    <dt><label for="email">E-Mail</label>
    <dd><input type="text" name="email" id="idEmail" /></dd>
  </dl>
  
  <dl>
    <dt><label for="name">Name</label></dt>
    <dd><input type="text" name="name" id="idName" /></dd>
  </dl>
  
  <dl>
    <dt><label for="surname">Surname</label></dt>
    <dd><input type="text" name="surname" id="idSurname" /></dd>
  </dt>
  
  <dl>
    <dt><label for="title">Title</label></dt>
      <dd><label for="mr">
         <input type="radio" name="title" id="RadioGroup2_0" value="นาย" checked="checked" />
        นาย</label>
        <label for="miss">
         <input type="radio" name="title" value="นาง" id="RadioGroup2_1" />
         นาง</label>
        <label for="Mrs">
         <input type="radio" name="title" value="นางสาว" id="RadioGroup2_2" />
         นางสาว</label></dd>
   </dl>
  
  <dl>
    <dt><label for="image_file">Image file</label></dt>
    <dd><input type="file" name="user_image" id="textfield4" /></dd>
  </dl>
</fieldset>
<script type="text/javascript">
	 		var RecaptchaOptions = {
	    		theme : 'clean'
	 		};
</script>
<script src="include/ucaptcha/jquerycaptcha.js" type="text/javascript"></script>
<?php
	require_once $_SERVER['DOCUMENT_ROOT']."/include/ucaptcha/recaptchalib.php";
	$publickey = "6Lce4s0SAAAAAOGuKC0FP9nFOzsUVWBQqidHqFGL"; // you got this from the signup page
	echo recaptcha_get_html($publickey);
?>
<fieldset class="register">
	<input type="submit" name="profile" id="button" value="register" />
</fieldset>
</form>
</div>
<!--  End Coding Here -->
<!--  End box -->
															</div>
														</div>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
</div>
<?php 
	include $_SERVER['DOCUMENT_ROOT']."/include/footer.php";
?>